package sort.test3_29;

public class BubbleSort {

    public  int[] bubbleSort(int[] nums){
        if (nums.length==0){
            return null;
        }
        int length = nums.length;
        for (int i = 0; i < length; i++) {
            for (int j =1; j < length-i; j++) {
                if (nums[j]<nums[j-1]){
                    int temp=nums[j];
                    nums[j]=nums[j-1];
                    nums[j-1]=temp;
                }

            }
        }




        return  nums;
    }

    public static void main(String[] args) {
        BubbleSort bubbleSort = new BubbleSort();
        int[] a={2,51,3,4,9};
        int[] ints = bubbleSort.bubbleSort(a);
        for (int b: ints
             ) {
            System.out.println(b);
        }
    }


}
